package com.baidu.web.action.base;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.baidu.domain.base.Standard;
import com.baidu.service.base.StandardService;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Namespace("/")
@ParentPackage("struts-default")
@Actions
@Controller
@Scope("prototype")
public class StandardAction extends ActionSupport implements
		ModelDriven<Standard> {

	// 模型驱动
	private Standard standard = new Standard();

	// 注入standardService
	@Autowired
	private StandardService standardService;

	@Override
	public Standard getModel() {
		return standard;
	}

	@Action(value = "standard_save", results = { @Result(name = "success", type = "redirect", location = "pages/base/standard.html") })
	public String save() {
		standardService.save(standard);
		System.out.println("添加..");
		return SUCCESS;
	}

}
